Skip to content

Fix numeric type casting in binary matrix read operations#98

Merged
stevevanhooser merged 1 commit intomainfrom
claude/fix-neuropixels-sample-reading-zPlzP
Apr 8, 2026
Merged

Fix numeric type casting in binary matrix read operations#98
stevevanhooser merged 1 commit intomainfrom
claude/fix-neuropixels-sample-reading-zPlzP

Conversation

@stevevanhooser
Copy link
Copy Markdown
Contributor

Summary

This PR adds explicit double-precision type casting to several numeric calculations in the binary matrix file reader to ensure consistent numeric handling and prevent potential type-related issues.

Key Changes

  • Cast num_channels to double in total samples calculation
  • Cast num_channels to double in bytes per sample calculation
  • Cast channel skip calculations to double for consecutive channel reads
  • Cast channel skip calculations to double for individual channel reads in loop

Implementation Details

The changes ensure that all intermediate calculations involving channel counts and skip offsets are performed using double-precision floating point arithmetic. This prevents potential issues with integer arithmetic overflow or type mismatches when dealing with large file sizes or channel counts. The explicit casting makes the numeric type handling more robust and consistent throughout the file reading operations.

https://claude.ai/code/session_01VLnP9PJcs7q2zxej9aTJAe

In MATLAB, double * uint32 = uint32, which silently overflows when
computing byte offsets for sample numbers exceeding ~2 billion (e.g.,
sample 15,321,600,000 in long Neuropixels recordings). Cast
num_channels, bytes_per_sample, and channel skip counts to double so
all intermediate arithmetic stays in double (53-bit mantissa, good to
~9e15).

https://claude.ai/code/session_01VLnP9PJcs7q2zxej9aTJAe
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Test Results

123 tests  ±0   123 ✅ ±0   4s ⏱️ -1s
 14 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 39433be. ± Comparison against base commit 4cca66a.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 31.98%. Comparing base (4cca66a) to head (39433be).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #98   +/-   ##
=======================================
  Coverage   31.98%   31.98%           
=======================================
  Files          92       92           
  Lines        4656     4656           
=======================================
  Hits         1489     1489           
  Misses       3167     3167           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stevevanhooser stevevanhooser merged commit 6548b71 into main Apr 8, 2026
5 checks passed
@stevevanhooser stevevanhooser deleted the claude/fix-neuropixels-sample-reading-zPlzP branch April 8, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants